#include "stdafx.h"
#include "Application.h"
#include "MiniDump.h"

Application::Application()
{
	myCursor = NULL;
}

Application::~Application()
{
	
}

bool Application::Init()
{
	myTestSprites.Init(30, 30);

	Graphics::Sprite* background = new Graphics::Sprite;
	background->Init("background.jpg");

	myTestSprites.Add(background);
	background->SetPosition(Vector2f(640.0f, 360.0f));

	myCursor = new Cursor;
	myCursor->Init("cursor.png");

	//WMInput::WM_InputWrapper::GetInstance()->LockMouse();

// 	for(float column = 0; column < 20; column++)
// 	{
// 		for(float row = 0; row < 12; row++)
// 		{
// 			Graphics::Sprite* square = new Graphics::Sprite;
// 			square->Init("square.png");
// 			square->SetPosition(Vector2f(column * 64.0f + 32.0f, row * 64.0f + 32.0f));
// 			myTestSprites.Add(square);
// 		}
// 	}

	return true;
}

void Application::Destroy()
{
	myTestSprites.DeleteAll();
	delete myCursor;
}

bool Application::Update()
{
	myCursor->Update();

	Graphics::Engine::GetInstance()->Update();
	Graphics::Engine::GetInstance()->Render();

	bool returnFlag = !WMInput::WM_InputWrapper::GetInstance()->KeyPressed(WMInput::KEY_ESCAPE);

	WMInput::WM_InputWrapper::GetInstance()->Update();

	return returnFlag;

	return true;
}